<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\BaseController;
use App\Jobs\VideoShortUrl;
use App\Lib\ImgCompressor;
use App\Lib\Kuaidi100;
use App\Lib\SnsapiLogin;
use Carbon\Carbon;
use GifCreator\GifCreator;
//use Intervention\Gif\Encoder;
use Intervention\Gif\Decoded;
use Intervention\Image\Facades\Image;
use Intervention\Gif\Encoder as Encoder;


class TestController extends BaseController
{

    public function test() {
        $app = $this->miniProgram();
        $content = 'https://qiniu.henjiyn.com/Fg8H8Cr14BgT-tlrRcakLRZg6oZL';

        $result = $app->content_security->checkImage($content);
        var_dump($result);exit;

//        $url = SnsapiLogin::getLoginUrl();
//        dd($url);
        SnsapiLogin::getUserInfo('061cUh4E0Ug47h27DQ1E0F0d4E0cUh4s');
        exit;
        $arr = [
            [
                'photo_content' => '婚礼',
                'photo_grade' => 'A-摄像助理',
                'price' => '500-100'
            ],
            [
                'photo_content' => '微电影',
                'photo_grade' => 'S-普通摄像',
                'price' => '100-200'
            ],
        ];
//        $arr = ['A-摄像助理', 'S-普通摄像'];
        echo json_encode_cn($arr);exit;
        Kuaidi100::handle([
            'com' => 'ems',
            'num' => '9862120028918'
        ]);
        exit;
        $out_trade_no = time();
        $total_amount = '0.01';
        $subject = 'test subject';
        $order = [
            'out_trade_no' => $out_trade_no,
            'total_amount' => $total_amount,
            'subject' => $subject,
        ];

        $alipay_url = $this->payApp()->app($order)->getContent();
        $app = $this->ttMini();
        $uid = 'kJxs.w-43GQ8HKPT';
        $response = $app->payment->pay($uid, $out_trade_no, $total_amount * 100, $subject, [
            'body' => 'test',
            'alipay_url' =>  $alipay_url,
            'valid_time' => '300',
            'notify_url' => 'http://beta.ling7.net/api/notify',
            'risk_info' => ''
        ]);

        return $this->success($response);
        exit;
        dispatch(new VideoShortUrl(1));
        return 11;
        exit;
        $frames = [];
        $k = 1;
        for ($i = 0;$i<=8;$i++) {
            $k = $k + 0.7;
            $aa = 'https://qiniu.huangxingle.top/2020050220384162168.mp4?vframe/jpg/w/350/offset/' . $k;
            array_push($frames, $aa);
        }

        $durations = array();
        for ($i = 0; $i <=10; $i++) {
            array_push($durations, 50);
        }

        // Initialize and create the GIF !
        $gc = new GifCreator();
        $gc->create($frames, $durations, 10);

        $gifBinary = $gc->getGif();
        file_put_contents('aaa.gif', $gifBinary);
//        header('Content-type: image/gif');
//        header('Content-Disposition: filename="butterfly.gif"');
//        echo $gifBinary;
        exit;
    }

}
